export function GetCalLists(){
  const self = this
  const _getEditHidden = function(params, self) {
      return params.row.wfStatus == 3 || self.fromPage == 'Summary'
  }
  let list = [
      {
        type: "selection",
        width: 45,
        align: "center"
      },
      {
        title: '业务单元',
        key: "trgNode",
      },
      {
        title: '一级分类',
        key: "firstType",
      },
      {
        title: '二级分类',
        key: "sedType",
      },
      {
        title: '应用名称',
        key: "appname",
      },
      {
          title: '更新时间',
           key: "updateTime",
           minWidth: 180,
      },
      {
        title: '状态',
        key: "wfStatusName",
        render: (h, params) => {
          return h('div',
          [
            h('p', {
              style:{
                display: 'inline-block',
                maxWidth: '80px',
                overflow: 'hidden', 
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap',
                color: params.row.wfStatusName == '驳回' ? '#E23928' : ''
              },
             }, params.row.wfStatusName),
            h('Tooltip', {
              props: {
                // trigger: "hover",
                transfer: true,
                placement:"left-end",
                maxWidth: '1000',
                content: '审批意见：' + ((params.row.approverComments == null || params.row.approverComments == '') ? '--' : params.row.approverComments)
              },
              style: {
                  // float: "right",
                  // backgroundColor: 'red'
                }
            }, [
                h('Icon', {
                  props: {
                    type: (!['审核通过', '驳回'].includes(params.row.wfStatusName) || (params.row.approverComments == null || params.row.approverComments == '')) ? '' : 'ios-book-outline'
                  },
                  style: {
                    fontSize: '18px',
                    position: 'relative',
                    top: '-5px',
                    left: '5px',
                    color: params.row.wfStatusName == '驳回' ? '#E23928' : ''
                  },
                })
              ])
          ])
        }
      },
      {
          title: '操作',
          align: "left",
          fixed: "right",
          width: 160,
          render: (h, params) => {
              return h("RowTools", {
                  props: {
                  data: [
                    {
                      type: "text",
                      text: '详情',
                      handle: () => {
                          this.goDetail(params.row);
                      }
                    },
                    {
                      type: "text",
                      text: '编辑',
                      hidden: _getEditHidden(params, self),
                      handle: () => {
                          this.goEdit(params.row);
                      }
                    },
                    {
                      type: "text",
                      text: '修订记录',
                      handle: () => {
                        this.revisionRecord(params.row);
                      }
                    }
                    // {
                    //   type: "text",
                    //   text: '导出',
                    //   hidden: !params.row.wfStatus || params.row.wfStatus == 2,
                    //   handle: () => {
                    //     this.exportFun(params.row);
                    //   }
                    // },
                    //   {
                    //   type: "text",
                    //   text: '删除',
                    //   hidden: params.row.wfStatus && params.row.wfStatus != 1,
                    //   handle: () => {
                    //     this.deleteFun(params.row);
                    //   }
                    // }
                  ]
                  }
              });
          }
      }
  ]
  // if (this.fromPage !== 'creater') {
  //   list.splice(4,1)
  // }
  if (this.fromPage == 'Summary') {
    // 数据管理页进入 删除复选框
    list.forEach((e, i) => {
      if(e.type == 'selection') {
        list.splice(i,1)
      }
    })
    // 删除状态
    list.forEach((e, i) => {
      if(e.key == 'wfStatusName') {
        list.splice(i,1)
      }
    })
  }
  return list
}

export function GetCalLists2(){
  const self = this
  const _getEditHidden = function(params, self) {
      return (params.row.operateStatus !== '1' && params.row.operateStatus !== '4') || self.fromPage == 'Summary'
  }
  const _getSubmitOrDelHidden = function(params, self) {
    return params.row.operateStatus !== '1' || self.fromPage == 'Summary'
  }
  const _getEditDisabled = function(params, self) {
    if (self.writePermission === false && (self.type == 'status' || self.type == 'rate')) {
      return true
    } else {
      return false
    }
  }
  const _getSubmitDisabled = function(params, self) {
    if (self.writePermission === false && (self.type == 'status' || self.type == 'rate')) {
      return true
    } else {
      return false
    }
  }
  
  let list = [
      {
        type: "selection",
        width: 45,
        align: "center"
      },
      {
        title: '业务单元',
        key: "trgNode",
      },
      {
        title: '填报周期',
        key: "reportCycle",
      },
      {
        title: '审批状态',
        key: "operateStatusName",
        render: (h, params) => {
          return h('div',
          [
            h('p', {
              style:{
                display: 'inline-block',
                maxWidth: '80px',
                overflow: 'hidden', 
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap',
                color: params.row.operateStatusName == '驳回' ? '#E23928' : ''
              },
             }, params.row.operateStatusName),
            h('Tooltip', {
              props: {
                // trigger: "hover",
                transfer: true,
                placement:"left-end",
                maxWidth: '1000',
                content: '审批意见：' + ((params.row.approverComments == null || params.row.approverComments == '') ? '--' : params.row.approverComments)
              },
              style: {
                  // float: "right",
                  // backgroundColor: 'red'
                }
            }, [
                h('Icon', {
                  props: {
                    type: (!['审核通过', '驳回'].includes(params.row.operateStatusName) || (params.row.approverComments == null || params.row.approverComments == '')) ? '' : 'ios-book-outline'
                  },
                  style: {
                    fontSize: '18px',
                    position: 'relative',
                    top: '-5px',
                    left: '5px',
                    color: params.row.operateStatusName == '驳回' ? '#E23928' : ''
                  },
                })
              ])
          ])
        }
      },
      {
          title: '更新时间',
           key: "updateTime",
           minWidth: 180,
      },
      {
          title: '创建时间',
           key: "createTime",
           minWidth: 180,
      },
      {
          title: '操作',
          align: "left",
          fixed: "right",
          width: 300,
          render: (h, params) => {
              return h("RowTools", {
                  props: {
                    data: [
                      {
                        type: "text",
                        text: '详情',
                        handle: () => {
                            this.goDetail(params.row);
                        }
                      },
                      {
                        type: "text",
                        text: '修改',
                        optType: _getEditDisabled(params, self) ? 'ashing': '',
                        hidden: _getEditHidden(params, self),
                        handle: () => {
                            if (this.writePermission === false) {
                              return
                            }
                            this.goEdit(params.row);
                        }
                      },
                      {
                        type: "text",
                        text: '提交',
                        optType: _getSubmitDisabled(params, self) ? 'ashing': '',
                        hidden: _getSubmitOrDelHidden(params, self),
                        handle: () => {
                          if (this.writePermission === false) {
                            return
                          }
                          this.submitFun(params.row);
                        }
                      },
                      {
                        type: "text",
                        text: '导出',
                        // hidden: !params.row.wfStatus || params.row.wfStatus == 2,
                        handle: () => {
                          this.exportFun(params.row);
                        }
                      },
                      {
                        type: "text",
                        text: '修订记录',
                        handle: () => {
                          this.revisionRecord(params.row);
                        }
                      }
                    ]
                  }
              });
          }
      }
  ]
  return list
}

export const calColumnList = [
  { columnName: '编码', columnKey: 'taskCode' },
  { columnName: '业务单元', columnKey: 'trgNode' },
  { columnName: '一级分类', columnKey: 'firstType', disabled: true },
  { columnName: '二级分类', columnKey: 'sedType', disabled: true },
  { columnName: '应用名称', columnKey: 'appname' },
  { columnName: '应用的数字化业务场景', columnKey: 'appCase', minWidth: 180 },
  { columnName: '应用的数字化技术', columnKey: 'appTech', minWidth: 160 },
  { columnName: '关键业务价值', columnKey: 'trgValue' },
  { columnName: '实施周期一年度', columnKey: 'year' },
  { columnName: '实施周期一周期', columnKey: 'round' },
  { columnName: '对应举措', columnKey: 'planNotice' },
  { columnName: '备注', columnKey: 'todo' },
  { columnName: '更新时间', columnKey: 'updateTime', minWidth: 160 },
  { columnName: '创建时间', columnKey: 'createTime', minWidth: 160 },
  { columnName: '状态', columnKey: 'wfStatusName',
    render: (h, params) => {
      return h('div',
      [
        h('p', {
          style:{
            display: 'inline-block',
            maxWidth: '80px',
            overflow: 'hidden', 
            textOverflow: 'ellipsis',
            whiteSpace: 'nowrap',
            color: params.row.wfStatusName == '驳回' ? '#E23928' : ''
          },
        }, params.row.wfStatusName),
        h('Tooltip', {
          props: {
            // trigger: "hover",
            transfer: true,
            placement:"top",
            maxWidth: '1000',
            content: '审批意见：' + ((params.row.approverComments == null || params.row.approverComments == '') ? '--' : params.row.approverComments)
            // ontent: '审批意见：' + params.row.approverComments
          },
          style: {
              // float: "right",
              // backgroundColor: 'red'
            }
        }, [
            h('Icon', {
              props: {
                // type: (params.row.wfStatusName == '审核通过' || params.row.wfStatusName == '驳回') ? 'ios-book-outline' : ''
                type: (!['审核通过', '驳回'].includes(params.row.wfStatusName) || (params.row.approverComments == null || params.row.approverComments == '')) ? '' : 'ios-book-outline'
              },
              style: {
                fontSize: '18px',
                position: 'relative',
                top: '-5px',
                left: '5px',
                color: params.row.wfStatusName == '驳回' ? '#E23928' : ''
              },
            })
          ])
      ])
    }
  }
]
